// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#include <cantor/function/type_traits.h>

namespace cantor {
    pb::TypeInfo CppTypeToTypeInfo<bool>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_BOOLEAN);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<int8_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_INT8);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<int16_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_INT16);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<int32_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_INT32);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<int64_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_INT64);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<turbo::int128>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_INT128);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<uint8_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_UINT8);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<uint16_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_UINT16);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<uint32_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_UINT32);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<uint64_t>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_UINT64);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<turbo::uint128>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_UINT128);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<Fp8Trait>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_FP8);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<Fp16Trait>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_FP16);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<float>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_FP32);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<double>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_FP64);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<std::string>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_STRING);
        info.mutable_string_type()->set_is_fixed(false);
        info.mutable_string_type()->set_length(-1);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<BinaryTrait>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_BINARY);
        info.mutable_binary_type()->set_is_fixed(false);
        info.mutable_binary_type()->set_length(-1);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<turbo::Time>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_TIMESTAMP);
        info.mutable_timestamp_type()->set_time_zone("local");
        info.mutable_timestamp_type()->set_precision(cantor::pb::TSP_NANO);
        return info;
    }

    pb::TypeInfo CppTypeToTypeInfo<turbo::Duration>::convert() {
        pb::TypeInfo info;
        info.set_type(pb::TYPE_KIND_DURATION);
        info.mutable_duration_type()->set_precision(cantor::pb::TSP_NANO);
        return info;
    }
} // namespace cantor
